package com.fr.base;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringUtils
{
  public static final String EMPTY = "";
  public static final String BLANK = " ";

  public static boolean isEmpty(String paramString)
  {
    return ((paramString == null) || (paramString.length() == 0));
  }

  public static boolean isNotEmpty(String paramString)
  {
    return (!(isEmpty(paramString)));
  }

  public static boolean isBlank(String paramString)
  {
    int i;
    if (paramString != null)
      if ((i = paramString.length()) != 0)
        break label15;
    return true;
    for (int j = 0; j < i; ++j)
      if (!(Character.isWhitespace(paramString.charAt(j))))
        label15: return false;
    return true;
  }

  public static boolean isNotBlank(String paramString)
  {
    return (!(isBlank(paramString)));
  }

  public static String trim(String paramString)
  {
    return ((paramString == null) ? null : paramString.trim());
  }

  public static String trimToNull(String paramString)
  {
    String str = trim(paramString);
    return ((isEmpty(str)) ? null : str);
  }

  public static String trimToEmpty(String paramString)
  {
    return ((paramString == null) ? "" : paramString.trim());
  }

  public static int stringToInt(String paramString)
  {
    return stringToInt(paramString, 0);
  }

  public static int stringToInt(String paramString, int paramInt)
  {
    try
    {
      return Integer.parseInt(paramString);
    }
    catch (NumberFormatException localNumberFormatException)
    {
    }
    return paramInt;
  }

  public static String perfectStart(String paramString1, String paramString2)
  {
    if (paramString1 == null)
      return paramString2;
    return paramString2 + paramString1;
  }

  public static String perfectEnd(String paramString1, String paramString2)
  {
    if (paramString1 == null)
      return paramString2;
    return paramString1 + paramString2;
  }

  public static String ignoreCaseReplaceAll(String paramString1, String paramString2, String paramString3)
  {
    Pattern localPattern = Pattern.compile(paramString2, 2);
    Matcher localMatcher = localPattern.matcher(paramString1);
    String str = localMatcher.replaceAll(paramString3);
    return str;
  }

  public static boolean equalsIgnore(String paramString1, String paramString2, String paramString3)
  {
    return perfectStart(perfectEnd(paramString1, paramString3), paramString3).equals(perfectStart(perfectEnd(paramString2, paramString3), paramString3));
  }

  public static boolean containChinese(String paramString)
  {
    if (isBlank(paramString))
      return false;
    return (!(paramString.matches("[^一-龥]*")));
  }
}